using OneCaps.Core.Models;

namespace OneCaps.Core.Interfaces
{
    /// <summary>
    /// 车牌识别服务接口
    /// </summary>
    public interface ILicensePlateRecognitionService
    {
        /// <summary>
        /// 识别车牌号
        /// </summary>
        /// <param name="imageData">图像数据</param>
        /// <returns>识别结果</returns>
        Task<LicensePlateRecognitionResult> RecognizeAsync(byte[] imageData);

        /// <summary>
        /// 识别车牌号（从文件路径）
        /// </summary>
        /// <param name="imagePath">图像文件路径</param>
        /// <returns>识别结果</returns>
        Task<LicensePlateRecognitionResult> RecognizeFromFileAsync(string imagePath);

        /// <summary>
        /// 批量识别车牌号
        /// </summary>
        /// <param name="imageDataList">图像数据列表</param>
        /// <returns>识别结果列表</returns>
        Task<IEnumerable<LicensePlateRecognitionResult>> RecognizeBatchAsync(IEnumerable<byte[]> imageDataList);

        /// <summary>
        /// 验证车牌号格式
        /// </summary>
        /// <param name="licensePlate">车牌号</param>
        /// <returns>是否有效</returns>
        bool ValidateLicensePlate(string licensePlate);

        /// <summary>
        /// 获取识别服务状态
        /// </summary>
        /// <returns>服务状态</returns>
        Task<RecognitionServiceStatus> GetServiceStatusAsync();
    }

    /// <summary>
    /// 车牌识别结果
    /// </summary>
    public class LicensePlateRecognitionResult
    {
        /// <summary>
        /// 是否识别成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 识别到的车牌号
        /// </summary>
        public string? LicensePlate { get; set; }

        /// <summary>
        /// 置信度（0-1）
        /// </summary>
        public double Confidence { get; set; }

        /// <summary>
        /// 识别耗时（毫秒）
        /// </summary>
        public long ProcessingTimeMs { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string? ErrorMessage { get; set; }

        /// <summary>
        /// 车牌位置信息
        /// </summary>
        public LicensePlateLocation? Location { get; set; }

        /// <summary>
        /// 车牌类型
        /// </summary>
        public LicensePlateType? PlateType { get; set; }

        /// <summary>
        /// 车牌颜色
        /// </summary>
        public string? PlateColor { get; set; }
    }

    /// <summary>
    /// 车牌位置信息
    /// </summary>
    public class LicensePlateLocation
    {
        /// <summary>
        /// 左上角X坐标
        /// </summary>
        public int X { get; set; }

        /// <summary>
        /// 左上角Y坐标
        /// </summary>
        public int Y { get; set; }

        /// <summary>
        /// 宽度
        /// </summary>
        public int Width { get; set; }

        /// <summary>
        /// 高度
        /// </summary>
        public int Height { get; set; }
    }

    /// <summary>
    /// 识别服务状态
    /// </summary>
    public class RecognitionServiceStatus
    {
        /// <summary>
        /// 服务是否可用
        /// </summary>
        public bool IsAvailable { get; set; }

        /// <summary>
        /// 服务版本
        /// </summary>
        public string? Version { get; set; }

        /// <summary>
        /// 模型版本
        /// </summary>
        public string? ModelVersion { get; set; }

        /// <summary>
        /// 平均识别时间（毫秒）
        /// </summary>
        public double AverageProcessingTimeMs { get; set; }

        /// <summary>
        /// 识别成功率
        /// </summary>
        public double SuccessRate { get; set; }

        /// <summary>
        /// 最后更新时间
        /// </summary>
        public DateTime LastUpdateTime { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string? ErrorMessage { get; set; }
    }
} 